package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.OrderSettingDao;
import com.jiangyg.mall.order.dto.OrderSettingDTO;
import com.jiangyg.mall.order.entity.OrderSetting;
import com.jiangyg.mall.order.vo.OrderSettingVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderSettingServiceImpl extends BaseServiceImpl<OrderSettingDao, OrderSetting> implements OrderSettingService {

    @Autowired
    public OrderSettingServiceImpl(OrderSettingDao orderSettingDao) {
        super(orderSettingDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<OrderSettingVO> selectPagination(Pagination<OrderSettingVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, OrderSettingVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(OrderSettingDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public OrderSettingVO selectById(Long orderSettingId) throws Exception {
        return this.executeSelectById(orderSettingId, OrderSettingVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> orderSettingIds) {
        return this.baseMapper.deleteBatchIds(orderSettingIds) > 0;
    }

}
